{% load rbac %}
<!-- 左侧侧边栏 -->
<aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">

        <!-- 侧边栏菜单 -->
        <ul class="sidebar-menu">
            <!-- Optionally, you can add icons to the links -->
            <li class="active"><a href="{% url 'system:index' %}"><i class="fa fa-indent"></i> <span>首页</span></a></li>

            {% static_menu request %}

            {% for menu in request.reveal_menu %}
                {% if not menu.url %}
                    <!--如果菜单没有url则这个二级菜单是一个菜单组，样式设置为treeview-->
                    <li class="treeview" id="{{ menu.code }}">
                        <a href="">
                            <i class="{{ menu.icon }}"></i><span>{{ menu.name }}</span>
                            <span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i>
                            </span>
                        </a>
                        <ul class="treeview-menu">
                            {% for sub in  menu.sub_menu %}
                                <!--获取二级菜单的子菜单，作为折叠组中的三级菜单 -->
                                <li id="{{ sub.code }}">
                                    <a href="{{ sub.url }}"><i class="fa fa-caret-right"></i>{{ sub.name }}</a>
                                </li>
                            {% endfor %}
                        </ul>
                    </li>
                {% else %}
                    <!-- 如果二级菜单有URL，则这是一个功能菜单，直接作为导航菜单，不再添加折叠样式 -->
                    <li id="{{ menu.code }}">
                        <a href="{{ menu.url }}"><i class="{{ menu.icon }}"></i><span>{{ menu.name }}</span>
                        </a>
                    </li>
                {% endif %}
            {% endfor %}
        </ul>
        <!-- /.sidebar-menu -->
    </section>
    <!-- /.sidebar -->
</aside>